package com.ymatou.alarm.testcase;



import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.alarm.parameter.SaveBatchBean;
import com.ymatou.alarm.service.SaveBatchCall;
import com.ymatou.iapi.alarm.parameter.SaveSingleBean;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.utils.YMTDateUtil;
/**
*批量保存错误日志Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SaveBatch{
	private static SaveBatchBean savebatchBean;
	private static SaveSingleBean savesingleBean;
	private static SaveBatchCall savebatchCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("批量保存错误日志Test");
	}

	@Before
	public void caseUp() {
		savesingleBean=new SaveSingleBean();
		savebatchBean=new SaveBatchBean();
		savebatchCall=new SaveBatchCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(savebatchCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SaveBatch_001() {
		Logger.start(true,"批量保存错误日志,成功");
		try {
			
			List<SaveSingleBean> Error=new ArrayList<SaveSingleBean>();			
			savesingleBean.setAppId("AppId1");
			savesingleBean.setReqUrl(null);
			savesingleBean.setReqForm(null);
			savesingleBean.setErrorLevel("1");
			savesingleBean.setMethodName("自动化测试");
			savesingleBean.setAssemblyName("abc");
			savesingleBean.setTitle("Title");
			savesingleBean.setMessage("Message");
			savesingleBean.setExceptionName("ExceptionName");
			savesingleBean.setHeader(null);
			savesingleBean.setStackTrace(null);
			savesingleBean.setAddTime(YMTDateUtil.getSysTime());
			savesingleBean.setMachineIp(null);			
			Error.add(savesingleBean);			
						
			SaveSingleBean msg2=new SaveSingleBean();			
			msg2.setAppId("AppId2");
			msg2.setReqUrl(null);
			msg2.setReqForm(null);
			msg2.setErrorLevel("2");
			msg2.setMethodName("自动化测试2");
			msg2.setAssemblyName("abcd");
			msg2.setTitle("Title2");
			msg2.setMessage("Message2");
			msg2.setExceptionName("ExceptionName2");
			msg2.setHeader(null);
			msg2.setStackTrace(null);
			msg2.setAddTime(YMTDateUtil.getSysTime());
			msg2.setMachineIp(null);
			Error.add(msg2);
													
			savebatchBean.setError(Error);
			savebatchCall.setData(savebatchBean);
			//savebatchCall.setData(savebatchBean);
			savebatchCall.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}